﻿
@{
    ViewBag.Title = "LoadForm";
}

<h2>Load Form</h2>
<div id="results"></div>
<div class="loading">
    <img src="~/Images/others/loading.gif" />
</div>

@section scripts{
    <script>
        $(function () {
            fnLoadMore();

            $(window).scroll(function () {
                if (Math.round($(window).scrollTop() + $(window).height()) == $(document).height()) {
                    if (pageNo < pageCount - 1) {
                        fnLoadMore();
                    }
                }
            });
        });

        var pageNo = 0;
        var pageCount = @ViewBag.PageCount
        function fnLoadMore() {
            if ($(".loading").css("display") == "none") {
                $(".loading").show();

                $.ajax({
                    url: "/Product/LoadMore",
                    data: { pageNo: pageNo },
                    success: function (response) {
                        $(response).appendTo("#results");
                        pageNo++;

                        $(".loading").hide();
                    }
                });
            }
        }
    </script>
}

